﻿using System;
using System.Windows.Data;
using System.Collections.Generic;
using System.ServiceModel.Syndication;

namespace ZFCNew.Converters
{
    public class ImageUrlConverter : IValueConverter
    {
        private const int defaultStringLength = 255;
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is IEnumerable<SyndicationLink>)
            {
                foreach (var url in (IEnumerable<SyndicationLink>)value)
                {
                    if (url.MediaType == "image/jpeg" || url.MediaType == "image/png")
                    {
                        return url.Uri;
                    }
                }
                
            }
            return null;           
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
